package net.tngou.crawler.action;

import java.io.IOException;

import javax.servlet.ServletException;

import org.apache.commons.lang.Validate;
import org.apache.commons.lang3.math.NumberUtils;

import net.tngou.crawler.enums.StateEnum;
import net.tngou.crawler.enums.TypeEnum;
import net.tngou.crawler.enums.ValidEnum;
import net.tngou.crawler.jdbc.OrderType;
import net.tngou.crawler.jdbc.PageUtil;
import net.tngou.crawler.pojo.Data;
import net.tngou.crawler.pojo.POJO;
import net.tngou.crawler.pojo.Tag;
import net.tngou.crawler.service.DataService;


/**
 * 数据
 * @author tngou@tngou.net
 *
 */
public class TagAction extends BaseAction {

	@Override
	public void execute() throws ServletException, IOException {
		int  valid=0;
		String[] rs = request.getParams();
		if(rs!=null&&rs.length>0&&NumberUtils.isNumber(rs[0]))
			valid=Integer.parseInt(rs[0]);
		PageUtil page = service.getPage(ask.getPage(), ask.getRows(), "valid="+valid, "count", OrderType.DESC, Tag.class);
		root.put("page", page);
		root.put("valid", valid);
		root.put("valids", ValidEnum.values());
		printFreemarker("tag.ftl", root);
		
	}
	
	public void add() {
		printFreemarker("tag_add.ftl", root);

	}
}
